const axios = require('axios');
const fs = require('fs');
const path = require('path');
// 直接使用硬编码的API密钥进行测试
const apiKey = 'z93GR0EjgAxakE1x5fiOlLvfVEypqFmhsN3k6TcgM2uAsNi7N9pu4RFv04IHM1UH';
const apiSecret = 'yGZBbcnm2ziHL3HBNqlC0dOo1ULLwPO91OnylYMVa3jFlO8ttfyuq4MdgcpNXSgSC';
const baseUrl = 'https://api.binance.com';

// 测试Binance API连接
async function testBinanceApi() {
    try {
      console.log('测试Binance API连接...');
      console.log('API密钥:', apiKey);
      console.log('API基础URL:', baseUrl);

      // 尝试获取BTCUSDT的最新价格 (无需API密钥的公共端点)
      const response = await axios.get(
        `${baseUrl}/api/v3/ticker/price?symbol=BTCUSDT`,
        {
          timeout: 5000
        }
      );

    console.log('API连接成功!');
    console.log('交易所状态:', response.data.status);
    console.log('可用交易对数量:', response.data.symbols.length);
  } catch (error) {
    console.error('API连接失败:', error.message);
    console.error('完整错误信息:', error);
  }
}

testBinanceApi();